# $Id: Makefile,v 1.1.1.1 2004/02/21 18:48:08 ibo Exp $
# tests makefile

all: tests

include ../Makefile.local
PERL      := perl -I$(PERLLIBS) -I../..
FOGEDIR   := ../FOGE2
TESTDIR   := .
FLOG      := tests.log
ERASEDB   := ./erasetables
CREATEDB  := ./erasetables -c

TESTNS	=	test00 test01 test02 test03 test04 test05 test06
TESTS     := test-msgfr test-msgja test01 # test02 test03 test04 test05 test06 
TESTSRPRT := ./testsreport

tests: eraselog $(TESTS) printsummary
eraselog:
	rm -f $(FLOG)
printsummary:
	$(TESTSRPRT) < $(FLOG)

${TESTNS} : test0% : test0%.pl $(DIRCGI)/test0%.cgi
	$(PERL) $@.cgi 'action=makesql' | $(CREATEDB)
	$(ERASEDB) "$(PGUSER)" $$($(PERL) $@.cgi 'action=printtablenames')
	printf "**** test %s, %s\n" "$@" "$$(date)" >> "$(FLOG)"
	-$(PERL) $< $(DIRWWW)/$@.cgi $@ "$(FLOG)"
test-%: test-%.pl
	printf "**** test %s, %s\n" "$@" "$$(date)" >> "$(FLOG)"
	-$(PERL) $< '' $@ "$(FLOG)"

# copy the script where the server can find it
$(DIRCGI)/test%.cgi: test%.cgi
	-export F=`cd ${FOGEDIR}/ && pwd` ; cd ${DIRCGI}/ && ln -sf $$F ./
	cp $< $@
	chmod 755 $@

clean:
	rm -f "$(FLOG)" *~
.PHONY: clean all tests test% eraselog printsummary
